﻿using Microsoft.Extensions.DependencyInjection;
using System;
namespace Athena.Performance.Service
{
    using Models;
    using Options;
    using Transport.DotNetty;
    class Program
    {
        private static IServiceProvider BuildServiceCollection(Action<IServiceCollection> action)
        {
            var serviceCollection = new ServiceCollection();
            serviceCollection.AddLogging();
            action?.Invoke(serviceCollection);
            return serviceCollection.BuildServiceProvider();
        }

        static void Main(string[] args)
        {
            var serviceProvider = BuildServiceCollection((serviceCollection) =>
            {
                serviceCollection.AddAthenaCore(new ServiceDescriptor()
                {
                    Id = "athena.xunit.test",
                    Name = "雅典娜RPC-Test"
                }, new AthenaOptions()
                {
                    RouteAddressOption = new RouteAddressOption()
                    {
                        FileServiceMultipleRouteDirectory = "C:\\athena\\routes"
                    }
                });
                serviceCollection.AddServiceRuntimeCore();
                serviceCollection.AddRouteCore();
                serviceCollection.AddFileRouteManager();
                serviceCollection.AddDotNettyTransport();
                serviceCollection.AddSingleton<IUser, User>();
            });
            serviceProvider.UseService();
            Console.WriteLine("Athena RPC Service Ready");
            Console.ReadKey();
        }
    }
}
